<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo Yii::$app->name;?> 后台管理</title>
<?php $this->HeaderView(['slide']);?>

<script type="text/javascript" src="<?php echo $this->root_dir; ?>/static/common/js/jquery.tablednd.js"></script>

</head>
<body class="view_form" id="view_form_Model">

        <form class="view-form-form" method="post" action="<?php echo $this->createUrl(['models/api', 'modelid'=>$model->modelid]);?>" enctype="multipart/form-data">
        <input type="hidden" id="catid" name="Models[modelid]" value="<?php echo $model->modelid;?>">
        <input type="hidden" id="type" name="Models[type]" value="<?php echo $model->type;?>">
        <input type="hidden" id="type" name="Models[tablename]" value="<?php echo $model->tablename;?>">
                    <div class="slideTxtBox mtop-0">
        <div class="hd">
                    <ul>
                <li id="list"><a href="javascript:;"><span></span>列表(list)</a></li>

                
            </ul>
                </div>
        <div class="bd">
                    <ul class="list">
            <table class="view-form-input" border="0" cellspacing="0" cellpadding="0" width="100%">
                <tbody>
                <?php
						foreach(['list', 'view', 'create', 'update'] as $v){
							if (isset($model->api[$v]['fields'])){
						?>
                      <tr>
                        <th valign="top" class="td-title"><label for="catid"><?php echo @$model->api[$v]['name'];?>：</label></th>
                        <td class="td-input">
                        
                        
                       
                        </td>
                    </tr>
                    <?php foreach($model->api[$v]['fields'] as $vv){?>
                    <tr>
                        <th valign="top" class="td-title"><label for="catid">设置：</label></th>
                        <td class="td-input">
                        <?php echo $vv;?>
                        <?php echo $this->context->models['fields'][$vv]['name'];?>
                        </td>
                    </tr>
                     <?php
					}
					}
						}
						?>
                        </tbody>
            </table>
            </ul>

            
                </div>
    </div>
    <input type="submit" value="提交" name="sbmt" class="btn-submit mt-10" style="margin-left:120px">
<?=$this->csrfToken()?>

    </form>
<script type="text/javascript">
jQuery(".slideTxtBox").slide({trigger:"click"});
$(function(){
	$('span.function-fields').click(function(){
		var tab = $('.slideTxtBox .hd li.on').attr('id');
		var field = $(this).prev().children('input').attr('value');
		$('.fields-function', 'ul.'+tab).slideUp(0);
		$('.fields-function-'+field, 'ul.'+tab).slideDown(500);
		$(this).addClass('on').siblings().removeClass('on');
	});
	$(".view-form-form").validate({	
		rules: {
			"Models[name]": {
				required: true,
			},
			"Models[tablename]": {
				required: true,
				remote: {
					url: "<?php echo $this->createUrl(['/models/check-tablename'])?>",     //后台处理程序
					type: "get",               //数据发送方式
					dataType: "json",           //接受数据格式   
					data: {  
					    modelid: '<?php echo $model->modelid?>',                   //要传递的数据
						tablename: function() {
							return $("#tablename").val();
						}
					}
			}
			}
		},
		messages: {
			"Models[name]": {
				required: '请输入模型名称',
			}
		}
	});
    $("#setting-index").tableDnD();	
	
});
</script> 
<?php $this->FooterView();?>
</body>
</html>
